home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / chevron.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  4KB  |  111 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import wx
  5. from gui.textutil import GetTextWidth
  6. from gui import skin
  7. from gui.toolbox import prnt
  8. from cgui import SimplePanel
  9. from config import platformName
  10.  
  11. class Chevron(SimplePanel):
  12.     
  13.     def __init__(self, parent, label = '', callapsedicon = None, expandedicon = None):
  14.         SimplePanel.__init__(self, parent)
  15.         if not callapsedicon:
  16.             pass
  17.         self.callapsedicon = skin.get('AppDefaults.icons.chevroncolapsed')
  18.         if not expandedicon:
  19.             pass
  20.         self.expandedicon = skin.get('AppDefaults.icons.chevronexpanded')
  21.         self.Label = label
  22.         self.CalcSize()
  23.         self._expanded = False
  24.         self.isdown = False
  25.         Bind = self.Bind
  26.         Bind(wx.EVT_PAINT, self.OnPaint)
  27.         Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
  28.         Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
  29.         Bind(wx.EVT_LEFT_DCLICK, (lambda e: pass))
  30.  
  31.     
  32.     def CalcSize(self):
  33.         iwidth = max([
  34.             self.callapsedicon.Width,
  35.             self.expandedicon.Width])
  36.         iheight = max([
  37.             self.callapsedicon.Height,
  38.             self.expandedicon.Height])
  39.         self.iconspace = wx.Size(iwidth, iheight)
  40.         fwidth = GetTextWidth(self.Label, self.Font)
  41.         fheight = self.Font.Height
  42.         self.MinSize = wx.Size(iwidth + fwidth + 12, max([
  43.             iheight,
  44.             fheight]) + 6)
  45.  
  46.     
  47.     def GetExpanded(self):
  48.         return self._expanded
  49.  
  50.     
  51.     def SetExpanded(self, expand):
  52.         self._expanded = expand
  53.         e = wx.CommandEvent(wx.wxEVT_COMMAND_CHECKBOX_CLICKED)
  54.         e.EventObject = self
  55.         e.SetInt(expand)
  56.         self.AddPendingEvent(e)
  57.         self.Refresh()
  58.  
  59.     Expanded = property(GetExpanded, SetExpanded)
  60.     
  61.     def OnPaint(self, event):
  62.         dc = wx.PaintDC(self)
  63.         rect = wx.RectS(self.Size)
  64.         if platformName != 'mac':
  65.             dc.Brush = wx.Brush(self.BackgroundColour)
  66.             dc.Pen = wx.TRANSPARENT_PEN
  67.             dc.DrawRectangleRect(rect)
  68.         
  69.         dc.Font = self.Font
  70.         (iwidth, iheight) = self.iconspace
  71.         icon = None if self.Expanded else self.callapsedicon
  72.         dc.DrawBitmap(icon, (iwidth // 2 - icon.Width // 2) + 3, (iheight // 2 - icon.Height // 2) + 3, True)
  73.         textrect = wx.Rect(iwidth + 9, 0, rect.width - iwidth + 9 - 3, rect.height)
  74.         dc.DrawLabel(self.Label, textrect, wx.ALIGN_LEFT | wx.ALIGN_TOP)
  75.  
  76.     
  77.     def OnLeftDown(self, event):
  78.         self.isdown = True
  79.  
  80.     
  81.     def OnLeftUp(self, event):
  82.         if self.isdown:
  83.             self.Expanded = not (self.Expanded)
  84.             self.isdown = False
  85.         
  86.         self.Refresh()
  87.  
  88.  
  89.  
  90. class F(wx.Frame):
  91.     
  92.     def __init__(self):
  93.         wx.Frame.__init__(self, None)
  94.         S = self.Sizer = wx.BoxSizer(wx.VERTICAL)
  95.         p = self.panel = wx.Panel(self)
  96.         S.Add(p, 1, wx.EXPAND)
  97.         s = p.Sizer = wx.BoxSizer(wx.VERTICAL)
  98.         chev = self.chev = Chevron(p, 'Expand')
  99.         chev.Bind(wx.EVT_CHECKBOX, (lambda e: prnt('clixxd', e.IsChecked())))
  100.         s.Add(chev, 0, wx.ALL, 10)
  101.  
  102.  
  103. if __name__ == '__main__':
  104.     from tests.testapp import testapp
  105.     hit = wx.FindWindowAtPointer
  106.     a = testapp('../../')
  107.     f = F()
  108.     f.Show(True)
  109.     a.MainLoop()
  110.  
  111.